package kolekcje.eng.powtorka;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class JukeboxSetter {
	
	public static String[] list = { "Pink Moon/Nick Drake",
		"Somersault/Zero 7", "Shiva Moon/Prem Joshua", "Circles/BT",
		"Deep Channel/Afro Celts", "Passenger/Headmix", "Listen/Tahiti 80" };
	
	public static File file = new File("songs.txt");

	public static void main(String[] args) {

		BufferedWriter bw;
		try {
			bw = new BufferedWriter(new FileWriter(file));
			for(String e : list)
				bw.write(e + "\r\n");
			bw.close();
			System.out.println("Zapisano plik " + file.getName());
			System.out.println(file.getAbsolutePath() + "\n");
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		
		try {
			BufferedReader br = new BufferedReader(new FileReader(file));
			String s;
			while((s = br.readLine()) != null)
				System.out.println(s);
			br.close();
		} catch (FileNotFoundException e) {
			System.out.println("Nie odnaleziono pliku");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
